package by.grsu.hdm.devices;

import by.grsu.hdm.model.HomeDevice;
import by.grsu.hdm.model.RCSignalAvailableEventListener;
import by.grsu.hdm.model.RCSignalAvailableEvent;
import by.grsu.hdm.software.MediaPlayer;

public class Receiver extends HomeDevice implements RCSignalAvailableEventListener {
	private String id;
	private MediaPlayer mediaPlayer;
	
	protected Receiver() {}
	
	public Receiver(String id, MediaPlayer mediaPlayer) {
		this.id = id;
		this.mediaPlayer = mediaPlayer;
	}
	
	public void rcSignalAvailableEvent(RCSignalAvailableEvent event) {
		switch(event.getRCSignal()) {
		case PlayPause:
			mediaPlayer.play();
			break;
		case PlayNext:
			mediaPlayer.playNext();
			break;
		case PlayPrevious:
			mediaPlayer.playPrevious();
			break;
		default:
			break;
		}
	}

	@Override
	public String getDeviceId() {
		return this.id;
	}

}
